import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const Home = () => import('../views/Home.vue')
const Index = () => import('../views/index/Index.vue')
const Product = () => import('../views/product/Product.vue')
const Detail = () => import('../views/detail/Detail.vue')
const Login = () => import('../views/login/Login.vue')
const Cart = () => import('../views/cart/Cart')
const Order = () => import('../views/Order')
const OrderConfirm = () => import('../views/orderConfirm/OrderConfirm')
const OrderList = () => import('../views/orderList/OrderList')
const OrderPay = () => import('../views/orderPay/OrderPay')
const Alipay = () => import('../views/alipay/Alipay')

const routes = [
    {
        path: '/', name: 'home', component: Home, redirect: '/index',
        children: [
            {path: '/index', name: 'index', component: Index},
            {path: '/product/:id', name: 'product', component: Product},
            {path: '/detail/:id', name: 'detail', component: Detail}
        ]
    },
    {path: '/login', name: 'login', component: Login},
    {path: '/cart', name: 'cart', component: Cart},
    {
        path: '/order', name: 'order', component: Order,
        children: [
            {path: 'confirm', name: 'order-confirm', component: OrderConfirm},
            {path: 'list', name: 'order-list', component: OrderList},
            {path: 'pay', name: 'order-pay', component: OrderPay},
            {path: 'alipay', name: 'alipay', component: Alipay},
        ]
    }
]

const router = new VueRouter({
    mode: 'history',
    base: process.env.BASE_URL,
    routes
})

export default router
